package com.zzw.bean;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 商品Elasticsearch文档映射类
 */
public class ProductES {
    private Integer id;            // 商品ID
    private String productCode;    // 商品编码
    private String productName;    // 商品名称
    private Integer categoryId;    // 分类ID
    private String categoryName;   // 分类名称
    private BigDecimal price;      // 标准售价
    private String unit;           // 计量单位
    private String specification;  // 规格型号
    private String description;    // 商品描述
    private String imageUrl;       // 商品图片URL
    private Integer status;        // 状态：0-禁用，1-启用
    private Date createTime;       // 创建时间
    private Date updateTime;       // 更新时间
    private Integer salesCount;    // 销量（用于推荐排序）
    private Float score;           // 评分（用于推荐排序）

    // 从Product转换为ProductES
    public static ProductES convertFromProduct(Product product) {
        ProductES productES = new ProductES();
        productES.setId(product.getId());
        productES.setProductCode(product.getProductCode());
        productES.setProductName(product.getProductName());
        productES.setCategoryId(product.getCategoryId());
        productES.setCategoryName(product.getCategoryName());
        productES.setPrice(product.getPrice());
        productES.setUnit(product.getUnit());
        productES.setSpecification(product.getSpecification());
        productES.setDescription(product.getDescription());
        productES.setImageUrl(product.getImageUrl());
        productES.setStatus(product.getStatus());
        productES.setCreateTime(product.getCreateTime());
        productES.setUpdateTime(product.getUpdateTime());
        productES.setSalesCount(0); // 默认销量
        productES.setScore(5.0f);  // 默认评分
        return productES;
    }

    // getter和setter方法
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getProductCode() {
        return productCode;
    }

    public void setProductCode(String productCode) {
        this.productCode = productCode;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public Integer getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Integer categoryId) {
        this.categoryId = categoryId;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public String getSpecification() {
        return specification;
    }

    public void setSpecification(String specification) {
        this.specification = specification;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getSalesCount() {
        return salesCount;
    }

    public void setSalesCount(Integer salesCount) {
        this.salesCount = salesCount;
    }

    public Float getScore() {
        return score;
    }

    public void setScore(Float score) {
        this.score = score;
    }
} 